feat: add fuzzing support with Atheris and Docker configuration#2177
Conversation
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
Up to standards ✅🟢 Issues
|
|
Hi, this is WorkflowBot.
|
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds ClusterFuzzLite-based fuzz testing infrastructure to the Python SDK, including a GitHub Actions workflow and a Dockerized build environment, plus several Atheris fuzz targets for core parsing/encoding paths.
Changes:
- Add a ClusterFuzzLite GitHub Actions workflow to build and run fuzzers on PRs and on
main. - Add a
.clusterfuzzlite/Docker + build script setup to build standalone fuzzer executables. - Add multiple Atheris fuzz targets for transaction deserialization, entity ID parsing, key parsing, and contract parameter encoding.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/clusterfuzzlite.yml |
Adds CI workflow to build/run ClusterFuzzLite fuzzers (PR and main builds). |
.codacy.yml |
Excludes .clusterfuzzlite/** from Codacy scanning. |
.clusterfuzzlite/Dockerfile |
Defines the Docker build environment used by ClusterFuzzLite. |
.clusterfuzzlite/build.sh |
Builds PyInstaller-packaged fuzzers and wrapper scripts for ClusterFuzzLite. |
.clusterfuzzlite/project.yaml |
Minimal ClusterFuzzLite project config (language: python). |
.clusterfuzzlite/transaction_from_bytes_fuzzer.py |
Fuzz target for Transaction.from_bytes() round-tripping. |
.clusterfuzzlite/entity_id_fuzzer.py |
Fuzz target for entity ID string parsing. |
.clusterfuzzlite/keys_fuzzer.py |
Fuzz target for private/public key parsing. |
.clusterfuzzlite/contract_params_fuzzer.py |
Fuzz target for ABI encoding via ContractFunctionParameters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds ClusterFuzzLite integration: Docker build, build script, four Atheris Python fuzz targets, project config, CI workflow to build/run fuzzers on PRs and pushes, excludes fuzz files from static analysis, and exports Changes
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions
participant Runner as Runner (hl-sdk-py-lin-md)
participant Docker as Docker Builder
participant BuildScript as .clusterfuzzlite/build.sh
participant PyInstaller as PyInstaller
participant Atheris as Atheris Runner
participant SDK as hiero_sdk_python
GHA->>Runner: trigger workflow (PR / push)
Runner->>Docker: build image from .clusterfuzzlite/Dockerfile
Docker->>BuildScript: run build script inside container
BuildScript->>SDK: generate protobufs, pip install package & deps
BuildScript->>PyInstaller: bundle each `*_fuzzer.py` into one-file exe
PyInstaller-->>BuildScript: output executables to $OUT
BuildScript->>BuildScript: write wrapper scripts (LD_PRELOAD, ASAN_OPTIONS)
Runner->>Atheris: run bundled fuzzers (code-change / run mode)
Atheris->>SDK: feed fuzz inputs to instrumented code paths
SDK-->>Atheris: return results or raise exceptions
Atheris->>GHA: report results, emit SARIF/crash artifacts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 84c67400-3cf5-4133-8ba1-5ac6fbc7832d
📒 Files selected for processing (9)
.clusterfuzzlite/Dockerfile.clusterfuzzlite/build.sh.clusterfuzzlite/contract_params_fuzzer.py.clusterfuzzlite/entity_id_fuzzer.py.clusterfuzzlite/keys_fuzzer.py.clusterfuzzlite/project.yaml.clusterfuzzlite/transaction_from_bytes_fuzzer.py.codacy.yml.github/workflows/clusterfuzzlite.yml
- Use null-delimited find loop in build.sh to safely handle filenames with spaces (SC2044) - Expand contract_params_fuzzer to cover address[] and bytes32[] array encoders (extends coverage from 8 to 10 encoding paths) - Remove redundant paths filter from workflow trigger (paths: ["**"] is equivalent to omitting it) Signed-off-by: Ntege Daniel <danientege785@gmail.com>
d17f944 to
a36dd29
Compare
Relax the lower bound from 3.0 to 2.99 seconds to account for microsecond-level precision variations in timing checks. The test was failing intermittently on Python 3.12 with delta values like 2.9999... which are technically valid but fell just under the strict 3.0 threshold. Signed-off-by: Ntege Daniel <danientege785@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #2177 +/- ##
=======================================
Coverage 93.73% 93.73%
=======================================
Files 145 145
Lines 9475 9477 +2
=======================================
+ Hits 8881 8883 +2
Misses 594 594 🚀 New features to boost your workflow:
|
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
|
@danielmarv please mark as ready to review when this is again, thanks |
|
@exploreriii was still checking out some stuffs |
|
@danielmarv Thanks for letting us know, will keep an eye out! |
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
manishdait
left a comment
There was a problem hiding this comment.
seems good to me need second opinion, @exploreriii or @aceppaluni
|
thanks for pointing out this |
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
…dk-python into fuzzle-sdk-br
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: cbf8001e-ca91-4293-b52c-f17a931a6f49
📒 Files selected for processing (3)
.clusterfuzzlite/contract_params_fuzzer.py.clusterfuzzlite/entity_id_fuzzer.py.clusterfuzzlite/transaction_from_bytes_fuzzer.py
|
@aceppaluni waiting on review please |
Up to standards ✅🟢 Issues
|
…o-ledger#2177) Signed-off-by: Ntege Daniel <danientege785@gmail.com>
Description:
This pull request introduces ClusterFuzzLite-based fuzz testing to the project, significantly improving the automated detection of bugs and vulnerabilities in the Python SDK. It adds GitHub Actions CI integration, Docker and build scripts, and a suite of fuzz targets covering key areas such as transaction deserialization, entity ID parsing, key parsing, and contract parameter encoding. The new setup leverages Atheris (Python fuzzing engine) and PyInstaller to build and run fuzzers in a reproducible environment.
Key changes include:
ClusterFuzzLite Integration and CI Automation
.github/workflows/clusterfuzzlite.yml) to automate building and running fuzzers on pull requests and pushes tomain, using the address sanitizer and reporting results via SARIF..clusterfuzzlite/Dockerfile) and build script (.clusterfuzzlite/build.sh) to set up the fuzzing environment, compile protobufs, install dependencies, and package fuzzers for ClusterFuzzLite. [1] [2].clusterfuzzlite/project.yaml).Fuzz Target Implementation
transaction_from_bytes_fuzzer.py: FuzzesTransaction.from_bytesdeserialization and re-serialization.entity_id_fuzzer.py: Fuzzes string parsing forAccountId,TokenId, andContractId.keys_fuzzer.py: Fuzzes parsing forPrivateKeyandPublicKeyfrom strings and bytes, with warning suppression.contract_params_fuzzer.py: Fuzzes ABI encoding forContractFunctionParameterswith various input types.Dependency Grouping for Fuzzing
fuzzinpyproject.tomlfor Atheris and PyInstaller, used only in the fuzzing environment and not included in standard development dependencies.These changes collectively establish a robust, automated fuzz testing pipeline to help catch bugs early and improve the reliability and security of the SDK.
Related issue(s):
Fixes #2143
Notes for reviewer:
Checklist